/**
 * Description: PageViewTestController.java
 * All Rights Reserved.
 * @version 1.0  2013-10-18 下午3:12:40  by 李青原（liqingyuan1986@aliyun.com）创建
 */
package controller.cartp;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zuche.framework.remote.RemoteClient;
import com.zuche.framework.remote.RemoteClientFactory;
import com.zuche.framework.remote.RemoteType;
import com.zuche.framework.tradingPlatform.*;
import com.zuche.framework.utils.PropertiesReader;
import com.zuche.framework.utils.SortSetMapper;
import com.zuche.framework.utils.StringUtils;
import org.jmesa.limit.Limit;
import org.jmesa.limit.LimitActionFactory;
import org.jmesa.model.PageItems;
import org.jmesa.model.TableModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 交易平台测试请求类 <br/>
 * Created on 2013-10-18 下午3:12:40
 * 
 * @author 李青原(liqingyuan1986@aliyun.com)
 * @since 1.0
 */
@Controller
public class TradingTestController_new {
	
	private static final Logger logger = LoggerFactory.getLogger(TradingTestController_new.class);
	// zxf memberId 2574039
	private String projectAddress;

	public TradingTestController_new() {
		this.projectAddress = PropertiesReader.getAppointPropertiesAttribute(
				"setting", "project_address", String.class);
	}

	@RequestMapping("/testMvcMode.do_")
	public ModelAndView testPageView(HttpServletRequest request,
			HttpServletResponse response) {
		String sourceId = ServletRequestUtils.getStringParameter(request,
				"sourceId", CurrenceSource.KUAIQIAN);

		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.SOURCE_ID, sourceId);
		paramMap.put(RequestParams.ASYNC_REPLY_URL, "http://10.101.32.67:8080/cartptest/test/testMvcModeReturn.do_");
		paramMap.put(RequestParams.BUSINESS_ID, "" + System.currentTimeMillis());
		paramMap.put(RequestParams.BUSINESS_MONEY, "0.01");
		paramMap.put(RequestParams.BUSINESS_NAME, "test");
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.WEB_BANK);
		paramMap.put(RequestParams.PRODUCT_COUNT, "1");
		paramMap.put(RequestParams.PRODUCT_ID, "1");
        paramMap.put(RequestParams.SYS_GROUP, "1");
        TradingServiceExecutor.doMvc(request, response, paramMap, true);
		return null;
	}

	@RequestMapping("/testEposPay.do_")
	public void testEposPay(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
				+ "/rpcReturn.do_");
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.EPOS_PAY);
		paramMap.put(RequestParams.PAYER_ID, "4947475");
		paramMap.put(RequestParams.CREDIT_ID, "339965");
//        paramMap.put(RequestParams.BIND_ID,"34720");
		paramMap.put(RequestParams.BUSINESS_MONEY, "19");
        paramMap.put(RequestParams.BUSINESS_ID, "2250710055423");
        paramMap.put(RequestParams.BUSINESS_NAME, "srms");
		paramMap.put(RequestParams.REDO, Boolean.TRUE.toString());
//		paramMap.put(RequestParams.IS_VALIDATE, Boolean.TRUE.toString());
		paramMap.put(RequestParams.IS_SCD, Boolean.FALSE.toString());
		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "chenzhimin");
		doRpc(request, response, paramMap);

	}
    @RequestMapping("/testEposYeePay.do_")
    public void testEposYeePay(HttpServletRequest request,
                            HttpServletResponse response) {
        Map<String, String> paramMap = new HashMap<String, String>();
        paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
                + "/rpcReturn.do_");
        paramMap.put(RequestParams.GROUP_TYPE,"yeepayCardPay");
//        paramMap.put(RequestParams.PAYER_NAME, "张俊亮");
        paramMap.put(RequestParams.PAYER_NAME, "ZHJL");
        paramMap.put(RequestParams.CARD_NO, "6214850220933086");
        paramMap.put(RequestParams.PAYER_TEL, "15902283216");
        paramMap.put(RequestParams.IDENTITY_ID, "142601198909049112");
        paramMap.put(RequestParams.IDENTITY_TYPE, "0");
        paramMap.put(RequestParams.SOURCE_ID, "CMB");
        paramMap.put(RequestParams.CARD_TYPE, "2");
        paramMap.put(RequestParams.BUSINESS_MONEY, "0.1");
        paramMap.put(RequestParams.BUSINESS_NAME, "test");
        paramMap.put(RequestParams.BUSINESS_ID, "" + System.currentTimeMillis());
        paramMap.put(RequestParams.SYS_GROUP, "5");
        paramMap.put(RequestParams.IS_VALIDATE, "true");
        paramMap.put(RequestParams.PAYER_ID, "5125100");
        doRpc(request,response,paramMap);
    }


	@RequestMapping("/testDirect.do_")
	public void testDirect(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
				+ "/rpcReturn.do_");
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.EPOS_PAY);

		paramMap.put(RequestParams.DIRECT_CARD, "1");
		paramMap.put(RequestParams.PAYER_NAME, "李青原");
		paramMap.put(RequestParams.CARD_NO, "6225760008714086");
		paramMap.put(RequestParams.CREDITCARD_EXPIREMONTH, "03");
		paramMap.put(RequestParams.CREDITCARD_EXPIREYEAR, "15");
		paramMap.put(RequestParams.CREDITCARD_CVV, "873");
		paramMap.put(RequestParams.PAYER_TEL, "18612697917");
		paramMap.put(RequestParams.IDENTITY_ID, "42100219861210183x");
		paramMap.put(RequestParams.SOURCE_ID, "CMB");

		paramMap.put(RequestParams.BUSINESS_ID, "aaa123123123");
		paramMap.put(RequestParams.BUSINESS_MONEY, "1");
		paramMap.put(RequestParams.BUSINESS_NAME, "test");
		doRpc(request, response, paramMap);
	}

	@RequestMapping("/testCardQuery.do_")
	public void testCardQuery(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.QUERY_CARD_INFO);
		paramMap.put(RequestParams.CARD_NO, "6217900100019858094");
		doRpc(request, response, paramMap);
	}

	/**
	 * 查询用户绑卡信息PCI
	 * @param request
	 * @param response
	 */
    @RequestMapping("/testPCIQuery.do_")
	public void testPCIQuery(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, "PCIQuery");//PCI查询接口名称
//		paramMap.put(RequestParams.PAYER_ID, "5125392");//交易人ID
		paramMap.put(RequestParams.PAYER_ID, request.getParameter("pciPayerId"));//交易人ID
        paramMap.put(RequestParams.CARD_TYPE, request.getParameter("pciCardType"));//卡类型（1：信用卡，2：储蓄卡）
        paramMap.put(RequestParams.SYS_GROUP, request.getParameter("pciSysGroup"));//0:租车账号
        doRpc(request, response, paramMap);
	}

	/**
	 * PCI删除
	 * @param request
	 * @param response
	 */
	@RequestMapping("/testPCIDel.do_")
	public void testPCIDel(HttpServletRequest request,HttpServletResponse response){
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, "PCIDel");//PCI查询接口名称
//		paramMap.put(RequestParams.PAYER_ID, "5125392");//交易人ID
		paramMap.put(RequestParams.PAYER_ID, request.getParameter("pciDPayerId"));//交易人ID
		paramMap.put(RequestParams.CARD_NO,request.getParameter("pciDCardNo"));//卡号625809******1270
		paramMap.put(RequestParams.SOURCE_ID,request.getParameter("pciDSourceId"));//银行简称
		paramMap.put(RequestParams.SYS_GROUP, request.getParameter("pciDSysGroup"));//0:租车账号
		doRpc(request, response, paramMap);
	}

	@RequestMapping("/testQuery.do_")
	public void testQuery(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.QUERY_WEB_BANK);
		doRpc(request, response, paramMap);
	}
	
 
	@RequestMapping("/testQueryZhimaScore.do_")
	public void testQueryZhimaScore(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, "queryZhimaScore");
		paramMap.put(RequestParams.IDENTITY_ID, "22240319880319601X");
		paramMap.put(RequestParams.PAYER_NAME, "陈志民");
		paramMap.put(RequestParams.SYS_GROUP, "1");
		paramMap.put(RequestParams.IS_TEST, "true");
		doRpc(request, response, paramMap);
	}

	/**
	 * 预授权
	 * @param request
	 * @param response
	 */
	@RequestMapping("/testAuthFreeze.do_")
	public void testAuthFreeze(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
				+ "/rpcReturn.do_");
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.EPOS_AUTH_FREEZE);
		paramMap.put(RequestParams.PAYER_ID, "5035617");
		paramMap.put(RequestParams.CREDIT_ID, "373464");
		paramMap.put(RequestParams.BUSINESS_ID, "14262104676323");
		paramMap.put(RequestParams.BUSINESS_MONEY, "10000");
		paramMap.put(RequestParams.BUSINESS_NAME, "srms");
		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "presentListId", "srmsquickpay_36158");
        paramMap.put(RequestParams.SYS_GROUP, "1");
        doRpc(request, response, paramMap);
	}

	@RequestMapping("/testPayRefund.do_")
	public void testPayRefund(HttpServletRequest request,
			HttpServletResponse response) {
		String recordId = request.getParameter("refundId");
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.EPOS_PAY_REFUND);
		paramMap.put(RequestParams.RECORD_ID, recordId);
		paramMap.put(RequestParams.SYS_GROUP, request.getParameter("sysGroup"));
		paramMap.put(RequestParams.IS_TEST, "false");
		paramMap.put(RequestParams.BUSINESS_MONEY, request.getParameter("money"));
		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "zm.chen");
		Map<String, String> result = TradingServiceExecutor.doRpc(paramMap,
				false);
		if(!"1".equals(result.get(ReplyRequestParams.STATUS))){
			logger.error("recordId_failed"+recordId);
//				System.out.println("recordId_failed"+recordId);
		}else{
			logger.error("success");
		}
	}

	@RequestMapping("/testPayCancel.do_")
	public void testPayCancel(HttpServletRequest request,
			HttpServletResponse response) {
		String recordId = request.getParameter("cancelId");
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.EPOS_PAY_CANCEL);
		paramMap.put(RequestParams.RECORD_ID, recordId);
		paramMap.put(RequestParams.SYS_GROUP, "1");
		paramMap.put(RequestParams.IS_TEST, "false");
		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "zm.chen");
		paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
				+ "/rpcReturn.do_");
		doRpc(request, response, paramMap);
	}

	/**
	 * 信用卡预授权撤单
	 * @param request
	 * @param response
	 */
	@RequestMapping("/testAuthCancel.do_")
	public void testAuthCancel(HttpServletRequest request,
			HttpServletResponse response) {
		String authCancelIds = request.getParameter("authCancelId");
		String[] auths = null;
		if(!StringUtils.isEmpty(authCancelIds) && authCancelIds.indexOf(",") != -1){
			auths = authCancelIds.split(",");
		}else{
			auths = new String[]{authCancelIds};
		}
		for(String id : auths){
			Map<String, String> paramMap = new HashMap<String, String>();
			paramMap.put(RequestParams.GROUP_TYPE, GroupType.EPOS_AUTH_CANCEL);
			paramMap.put(RequestParams.RECORD_ID, id);
			paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "liqingyuan");
			paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
					+ "/rpcReturn.do_");
			paramMap.put(RequestParams.SYS_GROUP,"1");
			doRpc(request, response, paramMap);
		}
	}

	@RequestMapping("/testAuthConfirm.do_")
	public void testAuthConfirm(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.EPOS_AUTH_CONFIRM);
		paramMap.put(RequestParams.RECORD_ID,
				request.getParameter("authConfirmId"));
		paramMap.put(RequestParams.BUSINESS_MONEY, "3000");
        paramMap.put(RequestParams.SYS_GROUP, "1");
        paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "liqingyuan");
		paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
				+ "/rpcReturn1.do_");
		doRpc(request, response, paramMap);
	}

	@RequestMapping("/testAuthConfCancel.do_")
	public void testAuthConfCancel(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.EPOS_AUTH_CONF_CANCEL);
		paramMap.put(RequestParams.RECORD_ID,
				request.getParameter("authConfCancelId"));
		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "liqingyuan");
		paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
				+ "/rpcReturn1.do_");
		doRpc(request, response, paramMap);
	}

	@RequestMapping("/testQueryWebSupport.do_")
	public void testQueryWebSupport(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.QUERY_WEB_BANK);
		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "liqingyuan");
		doRpc(request, response, paramMap);
	}

	@RequestMapping("/testQueryEposSupport.do_")
	public void testQueryEposSupport(HttpServletRequest request,
			HttpServletResponse response) throws InterruptedException {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.QUERY_EPOS_BANK);
		/*paramMap.put(RequestParams.CREDIT_ID, "2271");
		paramMap.put(RequestParams.PAYER_ID, "2852930");*/
		paramMap.put(RequestParams.SYS_GROUP, "1");
		paramMap.put(RequestParams.IS_TEST, "true");
		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "liqingyuan");
		doRpc(request, response, paramMap);
	}

	@RequestMapping("/testQueryOrder.do_")
	public void testQueryOrder(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.QUERY_ORDER);
		paramMap.put(RequestParams.BUSINESS_ID, "11422848800185");
		paramMap.put(RequestParams.BUSINESS_NAME, "carwsom_order");
		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "liqingyuan");
		doRpc(request, response, paramMap);
	}

	@RequestMapping("/testQueryOper.do_")
	public void testQueryOper(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.SYS_GROUP, "1");
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.QUERY_OPER);
		paramMap.put(RequestParams.RECORD_ID, request.getParameter("queryId"));
//		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "liqingyuan");
		Map<String, String> result = TradingServiceExecutor.doRpc(paramMap,true);
		String replyInfo = result.get("reply_tp_reply_info");
		JSONObject jsonObject = (JSONObject) JSONObject.parse(replyInfo);
		System.out.print("#####"+jsonObject.get("status"));
//		doRpc(request, response, paramMap);
	}

	@RequestMapping("/testQueryCardInfo.do_")
	public void testQueryCardInfo(HttpServletRequest request,
			HttpServletResponse response) {
		// 6225758319641493
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.QUERY_CARD_INFO);
		paramMap.put(RequestParams.SYS_GROUP, "1");
		paramMap.put(RequestParams.CARD_NO, request.getParameter("cardno"));
		paramMap.put("tp_is_query_support",request.getParameter("isQuerySupport").equals("1")?"true":"false");
		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "chenzm");
		doRpc(request, response, paramMap);
	}

	@RequestMapping("/testCreateNo.do_")
	public void testCreateNo(HttpServletRequest request,
			HttpServletResponse response) {
		// 6225758319641493
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.CREATE_NO);
		paramMap.put(RequestParams.BUSINESS_ID, "1111111CARSTORE");
		paramMap.put(RequestParams.BUSINESS_NAME, "test2");
        paramMap.put(RequestParams.SYS_GROUP, "0");
        paramMap.put(RequestParams.TARGET_GROUP, "posAuthFreeze");
        paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "chenzm");
		doRpc(request, response, paramMap);
	}

	@RequestMapping("/testCompleteInfo.do_")
	public void testCompleteInfo(HttpServletRequest request,
			HttpServletResponse response) {
		// 6225758319641493
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.QUERY_CARD_INFO);
		paramMap.put(RequestParams.CARD_NO, request.getParameter("cardno"));
		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "chenzm");
		doRpc(request, response, paramMap);
	}

	/**
	 * 微信支付
	 * @param request
	 * @param response
	 */
	@RequestMapping("/testWechat.do_")
	public void testWechatApp(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
//	      paramMap.put(RequestParams.GROUP_TYPE, GroupType.WECHAT_MOBILE);
       // paramMap.put(RequestParams.GROUP_TYPE, GroupType.WECHAT_UNIFY);
        paramMap.put(RequestParams.UNIFY_TYPE, "APP");
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.WECHAT_MOBILE);
        paramMap.put(RequestParams.ASYNC_REPLY_URL, "http://10.100.21.42:8011/carmapi/m/pay/reletPayReturn.action");
		paramMap.put(RequestParams.BUSINESS_ID, "14795389461181");
		paramMap.put(RequestParams.BUSINESS_MONEY, "1");
		paramMap.put(RequestParams.BUSINESS_NAME, "test");
		paramMap.put(RequestParams.PAYER_ID, "10676342");
		paramMap.put(RequestParams.SYS_GROUP, "0");
		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "liqingyuan");
		doRpc(request, response, paramMap);
	}
 


	@RequestMapping("/testNative.do_")
	public void testWechatNative(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.WECHAT_IMG);
		paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
				+ "/rpcReturn.do_");
		paramMap.put(RequestParams.BUSINESS_ID, "10141272511504999");
		paramMap.put(RequestParams.BUSINESS_MONEY, "0.11");
		paramMap.put(RequestParams.DISCOUNT_MONEY, "0.1");
		paramMap.put(RequestParams.BUSINESS_NAME, "test");
		paramMap.put(RequestParams.PAYER_ID, "5125392");
		paramMap.put(RequestParams.SYS_GROUP, "3");
		paramMap.put(RequestParams.TRADING_SECOND, "60");
		paramMap.put(RequestParams.CUSTOMIZED_FLAG + "selfParam", "zm.chen");
		doRpc(request, response, paramMap);
	}

	@SuppressWarnings("unchecked")
	@RequestMapping("/testRemote.do_")
	public void testRemote(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("isTest", 0);
		map.put("status", 1);
		List<Map<String, Object>> re = (List<Map<String, Object>>) RemoteClientFactory
				.getInstance()
				.executeToObject("cartp.recordService.query", map);
		System.out.println(re.get(0));
	}

	@SuppressWarnings("unchecked")
	@RequestMapping("/testRemotePage.do_")
	public ModelAndView testRemotePage(HttpServletRequest request,
			HttpServletResponse response) {
		ModelAndView mav = new ModelAndView("/index.jsp");
		LimitActionFactory limitActionFactory = new LimitActionFactory(
				"recordList", request.getParameterMap());
		Map<String, Object> param = new HashMap<String, Object>();

		param.put(
				"orderByColumn",
				SortSetMapper.getInstance().toStr(
						limitActionFactory.getSortSet()));
		param.put("defaultOrder", "o.request_time desc");
		param.put("startIndex", 1);
		param.put("endIndex", 10);
		param.put("isTest", 0);
		param.put("status", 1);

		// 调用远程服务接口
		RemoteClient instance = RemoteClientFactory.getInstance();
		final Map<String, Object> orderMap = (Map<String, Object>) instance
				.executeToObject("cartp.recordService.page", param);
		Collection<?> items = TableModelUtils.getItems("tableList", request,
				new PageItems() {
					@Override
					public int getTotalRows(Limit limit) {
						// return memberService.getRecordCount4Member(member);
						return (Integer) orderMap.get("recordCount");
					}

					@Override
					public Collection<?> getItems(Limit limit) {
						return (Collection<?>) orderMap.get("recordList");
					}
				});

		mav.addObject("items", items);
		return mav;
	}

	@RequestMapping("/BankProtocol99BillSearch.do_")
	public void billSearch(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		String mac = request.getParameter("MAC");
		String orderId = request.getParameter("orderId");
		String reqTime = request.getParameter("reqTime");
		String ext1 = request.getParameter("ext1");
		map.put("mac", mac);
		map.put("searchKey", orderId);
		map.put("reqTime", reqTime);
		map.put("orgstr", orderId + reqTime);
		map.put("ext1", ext1);
		map.put("orgstr", orderId + reqTime);
		map.put("businessType", 3);
		String re = (String) RemoteClientFactory.getInstance().executeToObject(
				"cartp.bankCardTrade.search", map);
		request.setAttribute("result", re);
		response.sendRedirect("success.jsp");
		System.out.println(re);
	}

	@RequestMapping("/BankProtocolLakalaSearch.do_")
	public void lakalaSearch(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		String ExtData = request.getParameter("ExtData");
		String orderId = request.getParameter("orderID");
		String MD5 = request.getParameter("MD5");
		String mercId = request.getParameter("MercId");
		String termId = request.getParameter("TermId");
		String refNumber = request.getParameter("RefNumber");
		String orgRefNum = request.getParameter("OrgRefNum");
		String amount = request.getParameter("OrdAmt");
		String transTime = request.getParameter("TransTime");
		String orderSta = request.getParameter("OrderSta");
		String payType = request.getParameter("PayType");
		map.put("extData", ExtData);
		map.put("orderID", orderId);
		map.put("md5", MD5);
		map.put("mercId", mercId);
		map.put("termId", termId);
		map.put("refNumber", refNumber);
		map.put("orgRefNum", orgRefNum);
		map.put("amount", amount);
		map.put("transTime", transTime);
		map.put("orderSta", orderSta);
		map.put("payType", payType);

		String re = (String) RemoteClientFactory.getInstance().executeToObject(
				"cartp.bankCardTrade4Lakala.search", map);
		request.setAttribute("result", re);
		response.sendRedirect("success.jsp");
		System.out.println(re);
	}

	@RequestMapping("/BankProtocolLakalaSearch1.do_")
	public void settle(HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("trademoney", "710");
		map.put("balanceNo", "2014120100008");
		map.put("memberName", "MJZ");
		map.put("userId", "1");
		RemoteClientFactory.getInstance().executeToObject(
				"cartp.bankCardTrade4Settle.process", map);
	}

	@SuppressWarnings("unchecked")
	@RequestMapping("/BankProtocolLakalaSearch2.do_")
	public void getAmtList(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		String param = "000333425056";
		List<String> lst = (List<String>) RemoteClientFactory.getInstance()
				.executeToObject("cartp.bankCardTrade99Bill.getAmtList", param);
		for (String str : lst) {
			System.out.println("输出结果：" + StringUtils.parseDouble(str));
		}
	}

	@RequestMapping("/AliDirectPay.do_")
	public void aliDirectPay(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.REDO, String.valueOf(false));
        paramMap.put(ReplyRequestParams.NOTIFY_URL,projectAddress
                 + "/rpcReturn.do_");
        paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
                 + "/rpcReturn.do_");
        paramMap.put(RequestParams.SYS_GROUP,"5");
        paramMap.put(RequestParams.BUSINESS_ID,"" + System.currentTimeMillis());
        paramMap.put(RequestParams.BUSINESS_MONEY,"1");
        paramMap.put(RequestParams.BUSINESS_NAME,"test");
//        paramMap.put(RequestParams.GROUP_TYPE, GroupType.ALI_SDK);
          paramMap.put(RequestParams.GROUP_TYPE, GroupType.WEB_BANK);
        paramMap.put(RequestParams.SOURCE_ID,CurrenceSource.ALIPAY_M);
        paramMap.put(RequestParams.PAYER_ID,"5125392");
        paramMap.put(RequestParams.PAYER_TEL,"15810074478");
//        doRpc(request, response, paramMap);
		TradingServiceExecutor.doMvcBySetting(request,response,paramMap);

	}

	/**
	 * 信用卡发短信
	 * @param request
	 * @param response
	 * @throws IOException
	 */
	@RequestMapping("/testcreateNoSms.do_")
	public void createNoSms(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		Map<String, String> paramMap = new HashMap<String, String>();
		   paramMap.put(RequestParams.ASYNC_REPLY_URL, "http://127.0.0.1:9080/cartptest/test/testRpcModeReturn.do_");
		   /*paramMap.put(RequestParams.IS_SCD,String.valueOf(true));
		   paramMap.put(RequestParams.GROUP_TYPE, GroupType.QUERY_CREDITCARD_BIND);
		   paramMap.put(RequestParams.PAYER_ID,"1580583");
		   paramMap.put(RequestParams.IS_TEST,"false");
			Map<String, String> result = TradingServiceExecutor.doRpc(paramMap,
					true);
			System.out.println(result);*/
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.CREATE_NO_SMS);
		paramMap.put(RequestParams.BUSINESS_MONEY,"1");

//		paramMap.put(RequestParams.CARD_NO, "6225760019538417");
//		paramMap.put(RequestParams.CREDITCARD_EXPIREMONTH, "09");
//		paramMap.put(RequestParams.CREDITCARD_EXPIREYEAR, "20");
//		paramMap.put(RequestParams.CREDITCARD_CVV, "954");
//		paramMap.put(RequestParams.PAYER_TEL, "15902283216");
//        paramMap.put(RequestParams.PAYER_NAME, "张俊亮");
//        paramMap.put(RequestParams.IDENTITY_ID, "142601198909049112");
//        paramMap.put(RequestParams.SOURCE_ID, "CMB");

		paramMap.put(RequestParams.CARD_NO, "6225758319307996");
//		paramMap.put(RequestParams.CARD_NO, "6258091642911270");
//		paramMap.put(RequestParams.CARD_NO, "4380880000000007");
		paramMap.put(RequestParams.CREDITCARD_EXPIREMONTH, "04");
		paramMap.put(RequestParams.CREDITCARD_EXPIREYEAR, "21");
		paramMap.put(RequestParams.CREDITCARD_CVV, "045");
		paramMap.put(RequestParams.PAYER_TEL, "15810074478");
		paramMap.put(RequestParams.PAYER_NAME, "裴承国");
		paramMap.put(RequestParams.IDENTITY_ID, "42108719901004731X");
//		paramMap.put(RequestParams.SOURCE_ID, "GDB");
		paramMap.put(RequestParams.SOURCE_ID, "CMB");


        paramMap.put(RequestParams.IDENTITY_TYPE,"0");
		paramMap.put(RequestParams.NATION_CODE, "");
		paramMap.put(RequestParams.PAYER_ID, "5125392");
		paramMap.put(RequestParams.DIRECT_CARD, "1");
        paramMap.put(RequestParams.SYS_GROUP, request.getParameter("sysGroup"));//租车账户
		paramMap.put(RequestParams.CARD_TYPE, "1");
        paramMap.put(RequestParams.IS_VALIDATE, "true");
		doRpc(request, response, paramMap);
	}


	@RequestMapping("/testunbindCreditCard.do_")
	public void unbindCreditCard(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.UNBIND_CREDIT_CARD);
		paramMap.put(RequestParams.BIND_ID, "33632");
        paramMap.put(RequestParams.SYS_GROUP, "3");
        paramMap.put(RequestParams.IS_TEST, "true");
		doRpc(request, response, paramMap);
	}

	/**
	 * 信用卡首次快捷支付
	 * @param request
	 * @param response
	 */
	@RequestMapping("/testEposPaySms.do_")
	public void testEposPaySms(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
				+ "/rpcReturn.do_");
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.EPOS_PAY_SMS);
		paramMap.put(RequestParams.IS_VALIDATE, "true");
		paramMap.put(RequestParams.VALID_CODE, "510478");
		paramMap.put(RequestParams.TOKEN, "393896690");
		paramMap.put(RequestParams.RECORD_ID, "01127257500133127");

//        paramMap.put("tp_is_autopay","2");

//		paramMap.put(RequestParams.CARD_NO, "6225760019538417");
//		paramMap.put(RequestParams.CREDITCARD_EXPIREMONTH, "09");
//		paramMap.put(RequestParams.CREDITCARD_EXPIREYEAR, "20");
//		paramMap.put(RequestParams.CREDITCARD_CVV, "954");
//		paramMap.put(RequestParams.PAYER_TEL, "15902283216");
//		paramMap.put(RequestParams.IDENTITY_ID, "142601198909049112");
//		paramMap.put(RequestParams.PAYER_NAME, "张俊亮");
//		paramMap.put(RequestParams.SOURCE_ID, "CMB");

		paramMap.put(RequestParams.CARD_NO, "6225758319307996");
//		paramMap.put(RequestParams.CARD_NO, "6258091642911270");
		paramMap.put(RequestParams.CREDITCARD_EXPIREMONTH, "04");
		paramMap.put(RequestParams.CREDITCARD_EXPIREYEAR, "21");
		paramMap.put(RequestParams.CREDITCARD_CVV, "045");
		paramMap.put(RequestParams.PAYER_TEL, "15810074478");
		paramMap.put(RequestParams.PAYER_NAME, "裴承国");
		paramMap.put(RequestParams.IDENTITY_ID, "42108719901004731X");
//		paramMap.put(RequestParams.SOURCE_ID, "GDB");
		paramMap.put(RequestParams.SOURCE_ID, "CMB");

		paramMap.put(RequestParams.NATION_CODE, "");
		paramMap.put(RequestParams.PAYER_ID, "5125392");
		paramMap.put(RequestParams.CARD_TYPE, "1");
		paramMap.put(RequestParams.DIRECT_CARD, "1");
		paramMap.put(RequestParams.SYS_GROUP, request.getParameter("sysGroup"));//付款账户

		doRpc(request, response, paramMap);
	}

	/**
	 * 储蓄卡发短信
	 * @param request
	 * @param response
	 * @throws IOException
	 */
    @RequestMapping("/testcreateNoSms2.do_")
    public void createNoSms2(HttpServletRequest request,
                             HttpServletResponse response) throws IOException {
        Map<String, String> paramMap = new HashMap<String, String>();
        paramMap.put(RequestParams.GROUP_TYPE, GroupType.CREATE_NO_SMS);
//        paramMap.put(RequestParams.GROUP_TYPE, "cardAuth");

        /*paramMap.put(RequestParams.CARD_NO, "6214850220933086");
        paramMap.put(RequestParams.PAYER_TEL, "15902283216");
        paramMap.put(RequestParams.IDENTITY_ID, "142601198909049112");
        paramMap.put(RequestParams.PAYER_NAME, "张俊亮");
        paramMap.put(RequestParams.SOURCE_ID, "CMB");*/

//        paramMap.put(RequestParams.CARD_NO, "6226632100897524");//6226632100897524,6228270021221208879
//        paramMap.put(RequestParams.PAYER_TEL, "18202529195");
//        paramMap.put(RequestParams.IDENTITY_ID, "120110198608170318");
//        paramMap.put(RequestParams.PAYER_NAME, "郭艳松");
//        paramMap.put(RequestParams.PAYER_ID, "95125100");
//        paramMap.put(RequestParams.SOURCE_ID, "CEB");

//		paramMap.put(RequestParams.CARD_NO, "6225880150931245");//6226632100897524,6228270021221208879
		paramMap.put(RequestParams.CARD_NO, "5528010000000001");//6226632100897524,6228270021221208879
		paramMap.put(RequestParams.PAYER_TEL, "15810074478");
		paramMap.put(RequestParams.IDENTITY_ID, "42108719901004731X");
		paramMap.put(RequestParams.PAYER_NAME, "裴承国");
		paramMap.put(RequestParams.PAYER_ID, "5125392");
		paramMap.put(RequestParams.SOURCE_ID, "CMB");
		paramMap.put(RequestParams.CARD_TYPE, "2");//必填，cartp默认为信用卡

        /*paramMap.put(RequestParams.IDENTITY_ID, "120109199010196539");
        paramMap.put(RequestParams.IDENTITY_TYPE, "0");
        paramMap.put(RequestParams.CARD_TYPE, "2");
        paramMap.put(RequestParams.BUSINESS_MONEY, "1");
        paramMap.put(RequestParams.DIRECT_CARD, "1");*/
        paramMap.put(RequestParams.SYS_GROUP, "0");
        paramMap.put(RequestParams.IS_TEST, "false");
        doRpc(request, response, paramMap);
    }

	/**
	 * 储蓄卡快捷支付
	 * @param request
	 * @param response
	 */
	@RequestMapping("/testEposPaySms3.do_")//
	public void testEposPaySms3(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
				+ "/rpcReturn.do_");
//		paramMap.put(RequestParams.GROUP_TYPE,"cardAuthVerify");
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.EPOS_PAY_SMS);
		paramMap.put(RequestParams.IS_VALIDATE, "true");//是否绑卡
		paramMap.put(RequestParams.VALID_CODE, "171469");
		paramMap.put(RequestParams.TOKEN, "394330396");
		paramMap.put(RequestParams.RECORD_ID, "21127257546250310");

        paramMap.put(RequestParams.CARD_NO, "6225880150931245");
        paramMap.put(RequestParams.PAYER_TEL, "15810074478");
        paramMap.put(RequestParams.IDENTITY_ID, "42108719901004731X");
        paramMap.put(RequestParams.PAYER_NAME, "裴承国");
        paramMap.put(RequestParams.PAYER_ID, "5125392");
        paramMap.put(RequestParams.SOURCE_ID, "CMB");
		paramMap.put(RequestParams.CARD_TYPE, "2");

		paramMap.put(RequestParams.SYS_GROUP, "1");
		paramMap.put(RequestParams.IS_TEST, "false");

		doRpc(request, response, paramMap);
	}

	/**
	 * 二次快捷支付
	 * @param request
	 * @param response
	 */
	@RequestMapping("/testEposPaySms2.do_")
	public void testEposPaySms2(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, String> paramMap = new HashMap<String, String>();
		paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
				+ "/rpcReturn.do_");
//		paramMap.put(RequestParams.GROUP_TYPE, GroupType.EPOS_PAY_SMS);
		paramMap.put(RequestParams.GROUP_TYPE, GroupType.EPOS_PAY_SMS);

		//------begin------专车cartp存放绑卡信息情况下需要的参数-------------
		paramMap.put(RequestParams.BIND_ID, "33816");//33634,33633
		//-------end-------专车cartp存放绑卡信息情况下需要的参数---------

		paramMap.put(RequestParams.BUSINESS_MONEY, "1");
		paramMap.put(RequestParams.BUSINESS_ID, ""+System.currentTimeMillis());
		paramMap.put(RequestParams.BUSINESS_NAME, "ucarcdms");
		paramMap.put(RequestParams.SYS_GROUP, "1");
		paramMap.put(RequestParams.IS_TEST, "TRUE");
		doRpc(request, response, paramMap);
	}

    //快捷再次支付短信
    @RequestMapping("/testQuickPaySms2.do_")
    public void testQuickPaySms2(HttpServletRequest request,
                                HttpServletResponse response) {
        Map<String, String> paramMap = new HashMap<String, String>();
        paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
                + "/rpcReturn.do_");
        paramMap.put(RequestParams.GROUP_TYPE, "eposQuickPaySms");
//        paramMap.put(RequestParams.PAYER_ID, "105125100");//
//        paramMap.put(RequestParams.BIND_ID, "33633");//33634,33633
        paramMap.put(RequestParams.PAYER_ID, "5125392");//
        paramMap.put(RequestParams.BIND_ID, "33693");//33634,33633
        paramMap.put(RequestParams.BUSINESS_MONEY, "0.1");
//        paramMap.put(RequestParams.BUSINESS_ID, "10141272511504");
        paramMap.put(RequestParams.BUSINESS_ID, ""+System.currentTimeMillis());
        paramMap.put(RequestParams.BUSINESS_NAME, "ucarcdms");
        paramMap.put(RequestParams.SYS_GROUP, "0");//支付账户
        paramMap.put(RequestParams.IS_TEST, "TRUE");
        doRpc(request, response, paramMap);
    }

    //快捷在次支付
    @RequestMapping("/testEposSecQuickPay.do_")
    public void testEposSecQuickPay(HttpServletRequest request,
                                HttpServletResponse response) {
        Map<String, String> paramMap = new HashMap<String, String>();
        paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
                + "/rpcReturn.do_");
        paramMap.put(RequestParams.GROUP_TYPE, "eposReQuickPay");
        paramMap.put(RequestParams.PAYER_ID, "5125392");//
        paramMap.put(RequestParams.BIND_ID, "33693");//33634,33633
        paramMap.put(RequestParams.BUSINESS_MONEY, "1");
        paramMap.put(RequestParams.BUSINESS_ID, "10141272511504999");
        paramMap.put(RequestParams.BUSINESS_NAME, "ucarcdms");
        paramMap.put(RequestParams.SYS_GROUP, "3");

        paramMap.put(RequestParams.RECORD_ID, "03327257133230646");
        paramMap.put(RequestParams.TOKEN, "391644596");
        paramMap.put(RequestParams.VALID_CODE, "563706");
        doRpc(request, response, paramMap);
    }

    @RequestMapping(value = "/testBankDrawing.do_")
    public void testBankDrawing(HttpServletRequest request,HttpServletResponse response) throws UnsupportedEncodingException {
        Map<String, String> paramMap = new HashMap<String, String>();
        paramMap.put(RequestParams.GROUP_TYPE, GroupType.DRAWING);
        paramMap.put(RequestParams.SOURCE_ID, CurrenceSource.SPDB);
        paramMap.put(RequestParams.CARD_BANK_NAME, "浦吉支行");
        paramMap.put(RequestParams.CARD_BANK_CITY, "北京");
        paramMap.put(RequestParams.PAYER_NAME, "李青原");
        paramMap.put(RequestParams.CARD_NO, "6217920681136904");
//        paramMap.put(RequestParams.CARD_NO, "6225760802298534");
        paramMap.put(RequestParams.BUSINESS_MONEY, "0.1");
        paramMap.put(RequestParams.BUSINESS_ID, System.currentTimeMillis() + "");
        paramMap.put(RequestParams.BUSINESS_NAME, "driverDrawing");
        paramMap.put(RequestParams.SYS_GROUP, "3");

        Map<String,String> result = TradingServiceExecutor.doRpc(paramMap, true);
        System.out.println(JSON.toJSON(result));
    }

    @RequestMapping("/testDrawQuery.do_")
    public void testDrawQuery(HttpServletRequest request,HttpServletResponse response) {
        Map<String, String> paramMap = new HashMap<String, String>();
        paramMap.put(RequestParams.ASYNC_REPLY_URL, projectAddress
                + "/rpcReturn.do_");
        paramMap.put(RequestParams.SYS_GROUP, "3");
        paramMap.put(RequestParams.GROUP_TYPE, GroupType.QUERY_DRAWING);
        paramMap.put(RequestParams.RECORD_ID, "03327267760507007");
        doRpc(request,response,paramMap);
    }

	@RequestMapping("/testYeepayBindQuery.do_")
	public void testYeepayBindQuery(HttpServletRequest request,HttpServletResponse response){
		Map<String,String> paramMap = new HashMap<String,String>();
		paramMap.put(RequestParams.SYS_GROUP,"5");
	}

	private void doRpc(HttpServletRequest request,
			HttpServletResponse response, Map<String, String> paramMap) {
		Map<String, String> result = TradingServiceExecutor.doRpc(paramMap,
				true);
		try {
			response.setContentType("text/html;charset=UTF-8");
			StringBuilder sb = new StringBuilder("");
			for (Field f : ReplyRequestParams.class.getDeclaredFields()) {
				if (result.containsKey(f.get(null).toString())) {
					sb.append(f.getName()).append(" = ")
							.append(result.get(f.get(null).toString()))
							.append("<br/>");
				}
			}
			for (String key : result.keySet()) {
				if (key.startsWith(RequestParams.CUSTOMIZED_FLAG)) {
					sb.append(key).append(" = ").append(result.get(key));
				}
			}
			if(result.get("reply_tp_channel") != null){
				sb.append("<br/>reply_tp_channel = ").append(result.get("reply_tp_channel"));
			}
			response.getWriter().write(sb.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 查询绑卡信息
	 */
	@RequestMapping("/testQueryBind.do_")
	@ResponseBody
	public Object testQueryBind(){
		Map<String, Object> map = new HashMap<String, Object>();
//        map.put("cardNo", "6225760019538417");
		map.put("payerId", "5125392");
//        map.put("bindId", "33822");
//        map.put("status", 1);
//        map.put("payerId", "105125100");
        map.put("isDriver", false);
//        map.put("status", 1);
//        map.put("isAutoPay", "2");
//        ExecutorService callBackService = Executors.newFixedThreadPool(50);
//        final String url = "http://10.104.3.40/cartp";//TCP
//        final String  url = "http://127.0.0.1:8081/cartp";//HESSIAN
        final String  url = "http://paypre.10101111.com/cartp";//HESSIAN
		final RemoteClient client = RemoteClientFactory.getInstance(url, RemoteType.HESSIAN);
		Object obj = client.executeToObject("cartp.creditcardbind.queryId", "5125392");//只对专车起作用
//        Object obj = client.executeToObject("cartp.creditcardbind.query", map);//查询司机绑卡信息，需要 isDriver参数
		return obj;
	}

}
